package com.t18;

import java.io.*;

import static net.mindview.util.Print.print;

/**
 * Created by xuyiwei on 2018/9/5.
 */
public class Blip3 implements Externalizable {
    private int i;
    private String s;
    public Blip3() {
        print("Blip3 Constructor");
    }
    public Blip3(int i, String s) {
        print("Blip3(String x,int a)");this.i = i;this.s = s;
    }
    public String toString(){
        return s+i;
    }
    @Override
    public void writeExternal(ObjectOutput out) throws IOException {
        print("Blip3.writeExternal");
        out.writeObject(s);
        out.writeInt(i);
    }
    @Override
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        print("Blip3.readExternal");
        s = (String)in.readObject();
        i = in.readInt();
    }
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Blip3 b = new Blip3(1,"adw");
        ObjectOutputStream o = new ObjectOutputStream(new FileOutputStream("Blip3.out"));
        o.writeObject(b);
        o.close();
        ObjectInputStream in = new ObjectInputStream(new FileInputStream("Blip3.out"));
        Blip3 blip3 = (Blip3) in.readObject();
        System.out.println(blip3);
    }
    /**
     * Blip3(String x,int a)
     Blip3.writeExternal
     Blip3 Constructor
     Blip3.readExternal
     adw1
     */

}
